using System.Collections;
using UnityEngine;

public class FireShotUI : MonoBehaviour
{
	public UISprite slider;

	public Color normalColor = Color.white;

	public Color shineColor = Color.red;

	public float blinkDuration = 0.1f;

	private bool initialized;

	private void Init()
	{
		if (!initialized)
		{
			slider.fillAmount = 0f;
			initialized = true;
		}
	}

	private void Awake()
	{
		Init();
	}

	public void SetFireAmount(float amount)
	{
		slider.fillAmount = amount;
		slider.color = normalColor;
		StopAllCoroutines();
		if (slider.fillAmount >= 1f)
		{
			StartFireAnim();
		}
	}

	private void StartFireAnim()
	{
		StartCoroutine(DoShowFireAnim());
	}

	private IEnumerator DoShowFireAnim()
	{
		while (true)
		{
			slider.color = shineColor;
			yield return new WaitForSeconds(blinkDuration);
			slider.color = normalColor;
			yield return new WaitForSeconds(blinkDuration);
		}
	}
}
